// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import Vant from 'vant'
// import Cookies from 'js-cookie'
import 'vant/lib/index.css'
import 'amfe-flexible'
import '@/assets/reset.css'
import '@/assets/index.css'
import '@/assets/styles/iconfont.css'
import vueEsign from 'vue-esign'
import {
  Drawer,
  Loading,
  Progress,
  Input,
  Select,
  Option,
  DatePicker,
  Step,
  Steps,
} from 'element-ui'
// import Vconsole from 'vconsole'
Vue.use(vueEsign)

// new Vconsole()

Vue.use(Vant)
Vue.use(Drawer)
Vue.use(Loading)
Vue.use(Progress)
Vue.use(Input)
Vue.use(Select)
Vue.use(Option)
Vue.use(DatePicker)
Vue.use(Step)
Vue.use(Steps)
Vue.config.productionTip = false
Vue.prototype.$baseUrl = true ? '' : ''

router.beforeEach((to, from, next) => {
  // if (to.meta.title) {
  //   document.title = to.meta.title
  //   next()
  // }
  let userInfo = JSON.parse(localStorage.getItem('userInfo')) || {}
  if (to.path != '/apply') {
    if (userInfo.id) {
      next()
    } else {
      next({
        path: '/apply',
      })
    }
  } else {
    next()
  }
  // let futureToken = localStorage.getItem('futureToken')
  // if (futureToken) {
  //   next()
  // } else {
  //   if (!whitePath.includes(to.path)) {
  //     next('/login')
  //   } else {
  //     next()
  //   }
  // }
  next()
})

// Vue.prototype.$cookies = Cookies

router.afterEach((route) => {
  window.scroll(0, 0)
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>',
})
// open -n /Applications/Google\ Chrome.app/ --args --disable-web-security  --user-data-dir=/Users/LeoLee/Documents/MyChromeDevUserData
